document.write('') document.write('
\n
\n
\n
\n
\n \n\n
\n \n\n \n \n \n \n \n
<\/td>\n $pass<\/span> =<\/span> cat C:\\powershell\\365securestring.txt |<\/span> convertto-securestring<\/span> <\/td>\n <\/tr>\n
<\/td>\n $mycred<\/span> =<\/span> new-object<\/span> -<\/span>typename System.Management.Automation.PSCredential -<\/span>argumentlist "<\/span>john@404john.com"<\/span><\/span>,<\/span>$pass<\/span> <\/td>\n <\/tr>\n
<\/td>\n $O365Session<\/span> =<\/span> New-PSSession<\/span> -<\/span>ConfigurationName Microsoft.Exchange -<\/span>ConnectionUri https://<\/span>ps.outlook.com<\/span>/<\/span>powershell -<\/span>Authentication Basic -<\/span>AllowRedirection -<\/span>Credential $mycred<\/span><\/td>\n <\/tr>\n
<\/td>\n Import-PSSession<\/span> $O365Session<\/span><\/td>\n <\/tr>\n
<\/td>\n Connect-MsolService<\/span> -<\/span>Credential $mycred<\/span><\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n